Skip to content

Conversation

@friday2su
Copy link

@friday2su friday2su commented Dec 28, 2025

This PR introduces util.stringifyEnv, a helper that serializes a plain JavaScript object into a .env-compatible string.

The utility validates input and safely handles quoting and escaping for values containing spaces, quotes, newlines, or other special characters. The behavior is conservative to ensure correctness and deterministic output.

This change is limited to serialization only. It does not parse or load .env files. Tests are included to cover common and edge cases.

…nheritance, error handling, and environment variable stringification.
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Dec 28, 2025
@BridgeAR
Copy link
Member

I am having difficulties understanding the goal here, can you please elaborate?

What should be solved here? Please check or contributions guids as well to adhere to them.

@friday2su
Copy link
Author

The goal is to provide a small, safe utility that serializes a plain object into a valid .env file string.

This solves the problem of repeatedly reimplementing .env formatting logic, especially around quoting, escaping, and newlines, which are easy to get wrong.

The change only adds serialization. It does not parse or load .env files. It validates input, produces deterministic output, and follows common .env conventions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants